Component({
    properties: {
        show: Boolean
    },
    data: {
        random: "",
        envelope: "",
        drink: "",
        truth: "",
        risk: ""
    },
    lifetimes: {
        attached: function() {
            var t = getApp().globalData.punishment;
            this.setData({
                random: t.random,
                envelope: t.envelope,
                drink: t.drink,
                truth: t.truth,
                risk: t.risk
            });
        },
        detached: function() {}
    },
    methods: {
        changeRandom: function(t) {
            getApp().globalData.punishment.random = t.detail.value, this.syncData();
        },
        changePunish: function(t) {
            console.log(t);
            var e = t.currentTarget.id, n = t.detail.value;
            getApp().globalData.punishment[e] = n;
            var a = getApp().globalData.punishment;
            if (!(a.envelope || a.drink || a.truth || a.risk)) return getApp().globalData.punishment[e] = !n, 
            void wx.showToast({
                icon: "none",
                title: "请保留一个惩罚"
            });
            this.syncData();
        },
        syncData: function() {
            var t = getApp().globalData.punishment;
            this.setData({
                random: t.random,
                envelope: t.envelope,
                drink: t.drink,
                truth: t.truth,
                risk: t.risk
            }), wx.setStorage({
                key: "punishment",
                data: t
            });
        },
        close: function() {
            console.log("close"), this.triggerEvent("changeSetting", {}, {});
        }
    }
});